package com.shop.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shop.entity.goods;
import com.shop.service.goodsServiceI;
import com.shop.service.goodsServiceImpl;

/**
 * Servlet implementation class goodsServlet
 */

/**
 * 
 * @类名 goodsServlet
 * @描述 TODO
 * @作者： 李健玖
 * @日期：2018年6月30日下午3:05:02
 */
@WebServlet("/goodsServlet")
public class goodsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		goodsServiceI goi=new goodsServiceImpl();
		try {
			List<goods> list=goi.findByAll();
			//通过request将获取到的数据传给页面
			request.setAttribute("list", list);
			//请求转发
			request.getRequestDispatcher("admin/goods.jsp").forward(request,response);
			
			for(goods goods : list){
				System.out.println(goods.getGoods());
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//创建业务层对象
		String Goods=request.getParameter("Goods");
		String Gname=request.getParameter("Gname");
		System.out.println(Goods+":"+Gname);
	}

}
